package ms.platform.system.service;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import ms.platform.system.dao.RoleDAO;
import ms.platform.system.model.AdminRole;
import ms.platform.system.model.Role;

@Service
@Transactional(propagation=Propagation.SUPPORTS)
public class RoleService {

	@Autowired
	private RoleDAO roleDAO;
	
	/**
	 * 根据用户id获取该用户的所有角色list
	 * @param id
	 * @return
	 */
	public List<Role> getAllRoleByAdminId(Integer id) {
		return roleDAO.getAllRoleByAdminId(id);
	}

	/**
	 * 根据id查询角色
	 * @param id
	 * @return
	 */
	public Role queryRoleById(Integer id) {
		return roleDAO.queryRoleById(id);
	}
	
	/**
	 * 根据角色名称查询角色
	 * @param name
	 * @return
	 */
	public Role queryRoleByName(String name) {
		return roleDAO.queryRoleByName(name);
	}

	/**
	 * 修改角色
	 * @param role
	 */
	public void update(Role role) {
		roleDAO.update(role);
	}

	/**
	 * 新增角色
	 * @param role
	 */
	public void insert(Role role) {
		roleDAO.insert(role);
	}

	/**
	 * 根据id删除角色
	 * @param id
	 */
	public void deleteById(Integer id) {
		roleDAO.deleteById(id);
	}
	
	public void insertAdminRole(AdminRole adminRole) {
		roleDAO.insertAdminRole(adminRole);
	}
	
	public void deleteAdminRole(AdminRole adminRole) {
		roleDAO.deleteAdminRole(adminRole);
	}
	
	/**
	 * 带条件分页查询list
	 * @param map
	 * @return
	 */
	public List<Role> queryRoleListByCondition(Map<String, Object> map) {
		return roleDAO.queryRoleListByCondition(map);
	}

	/**
	 * 分页查询获取总条数
	 * @param map
	 * @return
	 */
	public Integer queryRoleCount(Map<String, Object> map) {
		return roleDAO.queryRoleCount(map);
	}

	public AdminRole queryAdminRole(AdminRole adminRole){
		return roleDAO.queryAdminRole(adminRole);
	}
	

}
